package com.roadmap.entities;

import com.roadmap.common.BaseConst;
import com.roadmap.common.BaseEntity;

public class Message extends BaseEntity {
	private String dispatcherId;
	private String dialogId;
	private int status;
	private String content;

	public Message() {
		this.status = BaseConst.MESSAGE_STATUS_UNREAD;
		this.setUpdatedTime(null);
	}

	public String getDispatcherId() {
		return dispatcherId;
	}

	public void setDispatcherId(String dispatcherId) {
		this.dispatcherId = dispatcherId;
	}

	public String getDialogId() {
		return dialogId;
	}

	public void setDialogId(String dialogId) {
		this.dialogId = dialogId;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	/**
	 * clone an instance which has the identical property values with the
	 * present one
	 */
	public Message clone() {
		Message msg = new Message();
		msg.setContent(this.getContent());
		msg.setCreatedTime(this.getCreatedTime());
		msg.setDispatcherId(this.getDispatcherId());
		msg.setId(this.getId());
		msg.setStatus(this.getStatus());
		msg.setUpdatedTime(this.getUpdatedTime());
		return msg;
	}

	@Override
	public String getWhatItIs() {
		if(getContent()!= null && getContent().length() > DESP_MAX_LENGTH){
			return getContent().substring(0, DESP_MAX_LENGTH) + "...";
		}
		return getContent();
	}
}
